/*
 * Solution.h
 *
 *  Created on: Feb 23, 2011
 *      Author: santiago
 */

#ifndef SOLUTION_H_
#define SOLUTION_H_

#include <vector>
#include "TSPCostMatrix.h"
#include "TSPPath.h"

using namespace std;

class Solution {
public:
	Solution();
	Solution(TSPCostMatrix *cost_matrix);
	Solution(TSPCostMatrix &cost_matrix);
	Solution(const Solution &original);
	virtual ~Solution();

	Solution& operator=(const Solution &sol);

	void add_link(unsigned int node_index_1, unsigned int node_index_2);
	void del_link(unsigned int node_index_1, unsigned int node_index_2);
	bool has_link(unsigned int node_index_1, unsigned int node_index_2) const;
	void get_links(unsigned int node_index, vector<unsigned int> &node_links) const;
	unsigned int get_links_count(unsigned int node_index) const;

	void add_path(const TSPPath &p);
	void del_path(const TSPPath &p);
	double get_cost_to_add(const TSPPath &p) const;

	double get_cost() const;
	bool check_factibility() const;
	TSPCostMatrix* get_costMatrix() const;

	void show() const;

	void clone_to(Solution *cloned_solution);
private:
	void convert_to_matrix(unsigned int node_index_1, unsigned int node_index_2,
			unsigned int &first_node_index, unsigned int &second_node_index) const;

	double _solution_cost;
	vector<vector<bool> > _links;
	TSPCostMatrix *_cost_matrix;
};

#endif /* SOLUTION_H_ */
